<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function copySorted(a = []) {
        const newArr = a.slice(0);
        // const newArr = a.map((v) => v);
        // const newArr = a.join(",").split(",");
        newArr.sort((a, b) => (a > b ? 1 : -1));
        return newArr;
      }
      let arr = ["HTML", "JavaScript", "CSS"];
      let sorted = copySorted(arr);
      console.log(sorted); // CSS, HTML, JavaScript
      console.log(arr); // HTML, JavaScript, CSS (no changes)
    </script>
  </body>
</html>
